#ifndef ISTORAGE_H
#define ISTORAGE_H

#include <QtCore/QSharedPointer>

QT_BEGIN_NAMESPACE
class QByteArray;
class QUrl;
QT_END_NAMESPACE

namespace core
{
class IPersistentDocument;
class MimeType;

class IStorage
{
public:
    virtual QByteArray read(const QSharedPointer<IPersistentDocument>&
        document) const = 0;
    virtual void write(
        const QSharedPointer<IPersistentDocument>& document) const = 0;
    virtual bool create(
        const QUrl& url) const = 0;
    virtual bool erase(const QSharedPointer<IPersistentDocument>&
        document) const = 0;

    virtual bool exists(
        const QUrl& url) const = 0;

    virtual QString registeredName() const = 0;
    virtual QString name() const = 0;

    virtual QUrl urlForSave(const QString& proposedName,
        const core::MimeType& mimeType, bool& canceled) const = 0;
    virtual QUrl urlForOpen(const core::MimeType& mimeType) const = 0;

    virtual bool operator==(const IStorage& storage) const = 0;

    virtual ~IStorage() {}

protected:
    friend class Persistence;

    virtual IStorage* copy() const = 0;
};

} // namespace core

#endif
